package it.eng.area118.mdocommon.view.utility;

import java.util.HashMap;

import android.widget.ViewFlipper;

public class FlipperIndexFactory {

	protected HashMap<Integer, Integer> mapIndexes;

	protected ViewFlipper flipper;

	public FlipperIndexFactory(ViewFlipper flipper) {
		super();
		this.flipper = flipper;
	}

	public HashMap<Integer, Integer> getMapIndexes() {
		if (mapIndexes == null) {
			mapIndexes = new HashMap<Integer, Integer>();
		}
		return mapIndexes;
	}

	public void setMapIndexes(HashMap<Integer, Integer> mapIndexes) {
		this.mapIndexes = mapIndexes;
	}

	public ViewFlipper getFliper() {
		return flipper;
	}

	public void setFliper(ViewFlipper flipper) {
		this.flipper = flipper;
	}
	

	public Integer addView(Integer viewId) {
		Integer newIndex = flipper.getChildCount();
		getMapIndexes().put(viewId, newIndex);
		return newIndex;
	}

	
	public Integer getIndexByViewId(Integer viewId) {
		if (mapIndexes.containsKey(viewId)) {
			return mapIndexes.get(viewId);
		}
		return -1;
	}

}
